home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / ActionDescriptor.java < prev    next >
Text File  |  1998-10-19  |  7KB  |  196 lines

  1. package com.symantec.itools.vcafe.beans;
  2.  
  3.  
  4. //  07/01/97    CAR Created
  5.  
  6. /**
  7.  * A simple class that encapsulates a bean's Visual CafΘ "action" information as used
  8.  * by the Interaction Wizard.  A Visual CafΘ action implies a relationship between
  9.  * objects (or between an object and itself) involving either event notification or data
  10.  * transmission.  The Interaction Wizard allows users to graphically build these relationships
  11.  * between objects and then Visual CafΘ is able to generate the code for the specified
  12.  * relationship based on the underlying action information encapsulated in the
  13.  * ActionDescriptor.
  14.  *
  15.  * @version 1.0, July 1, 1997
  16.  *
  17.  * @author  Symantec
  18.  */
  19. public class ActionDescriptor
  20.     extends java.beans.FeatureDescriptor
  21. {
  22.     /**
  23.      * A constant indicating an input action.
  24.      * @see #setForm
  25.      */
  26.     public static final String INPUT        = "input";
  27.     /**
  28.      * A constant indicating an output action.
  29.      * @see #setForm
  30.      */
  31.     public static final String OUTPUT       = "output";
  32.  
  33.     /**
  34.      * Constructs a default ActionDescriptor. Form, type, init, and expr
  35.      * are all empty strings.
  36.      * @see #setForm
  37.      * @see #setType
  38.      * @see #setInit
  39.      * @see #setExpr
  40.      */
  41.     public ActionDescriptor() {
  42.         form = "";
  43.         type = "";
  44.         init = "";
  45.         expr = "";
  46.     }
  47.  
  48.     /**
  49.      * Constructs a ActionDescriptor with the given form.
  50.      * Type, init, and expr are all empty strings.
  51.      * @param f the form string
  52.      * @see #setType
  53.      * @see #setInit
  54.      * @see #setExpr
  55.      */
  56.     public ActionDescriptor(String f) {
  57.         if (f != INPUT && f != OUTPUT)
  58.             throw new IllegalArgumentException("acceptable values are \"input\" or \"output\"");
  59.         form = f;
  60.         type = "";
  61.         init = "";
  62.         expr = "";
  63.     }
  64.  
  65.     /**
  66.      * Constructs a ActionDescriptor with the given form, type, and
  67.      * expr String values.
  68.      * @param f the form string
  69.      * @param t the type string
  70.      * @param e the expression string
  71.      * @param d a short description
  72.      */
  73.     public ActionDescriptor(String f, String t, String e, String d) {
  74.         if (f != INPUT && f != OUTPUT)
  75.             throw new IllegalArgumentException("acceptable values are \"input\" or \"output\"");
  76.         form = f;
  77.         type = t;
  78.         init = "";
  79.         expr = e;
  80.         if (expr != null && expr.startsWith(".import"))
  81.             System.err.println("**Warning: Import specifications are not supported in action descriptors");
  82.         setShortDescription(d);
  83.     }
  84.  
  85.     /**
  86.      * Constructs a ActionDescriptor with the given form, type, init, and
  87.      * expr String values.
  88.      * @param f the form string
  89.      * @param t the type string
  90.      * @param i the init string
  91.      * @param e the expression string
  92.      * @param d a short description
  93.      * @deprecated
  94.      */
  95.     public ActionDescriptor(String f, String t, String i, String e, String d) {
  96.         if (f != INPUT && f != OUTPUT)
  97.             throw new IllegalArgumentException("acceptable values are \"input\" or \"output\"");
  98.         form = f;
  99.         type = t;
  100.         init = i;
  101.         if (init != null && !init.equals("")) {
  102.             System.err.println("**Warning: Non-blank initialization strings are not supported in action descriptors");
  103.             throw new IllegalArgumentException("initialization string is not supported");
  104.         }
  105.         expr = e;
  106.         if (expr != null && expr.startsWith(".import"))
  107.             System.err.println("**Warning: Import specifications are not supported in action descriptors");
  108.         setShortDescription(d);
  109.     }
  110.  
  111.     /**
  112.      * Gets the current form string.
  113.      * @return the current form
  114.      * @see #setForm
  115.      */
  116.     public String getForm() { return form; }
  117.  
  118.     /**
  119.      * Sets the form string. The form of a action is either INPUT or OUTPUT. An output
  120.      * action defines an interaction that returns data; an input action defines an
  121.      * interaction that sets data, or initiates execution of a method that doesn't take data.
  122.      * @return the new form
  123.      * @see #getForm
  124.      */
  125.     public void setForm(String f) {
  126.         if (f != INPUT && f != OUTPUT)
  127.             throw new IllegalArgumentException("acceptable values are \"input\" or \"output\"");
  128.         form = f;
  129.     }
  130.  
  131.     /**
  132.      * Gets the current type string.
  133.      * @return the current type
  134.      * @see #setType
  135.      */
  136.     public String getType() { return type; }
  137.  
  138.     /**
  139.      * Specifies the Java type of the parameter or return value of this action.  The most
  140.      * common types are int, boolean, String, and void.
  141.      * @return the new type
  142.      * @see #getType
  143.      */
  144.     public void setType(String t) { type = t; }
  145.  
  146.     /**
  147.      * Gets the current init string.
  148.      * @return the current init
  149.      * @see #setInit
  150.      */
  151.     public String getInit() { return init; }
  152.  
  153.     /**
  154.      * Specifies any initialization code that needs to be present prior to the code generated from
  155.      * the action expression.  This string must be blank. The feature is not supported in this release.
  156.      * @return the new init
  157.      * @see #getInit
  158.      * @see #setExpr
  159.      * @deprecated
  160.      */
  161.     public void setInit(String i) {
  162.         init = i;
  163.         if (init != null && !init.equals("")) {
  164.             System.err.println("**Warning: Non-blank initialization strings are not supported in action descriptors");
  165.             throw new IllegalArgumentException("initialization string is not supported");
  166.         }
  167.     }
  168.  
  169.     /**
  170.      * Gets the current expression string.
  171.      * @return the current expression
  172.      * @see #setExpr
  173.      */
  174.     public String getExpr() { return expr; }
  175.  
  176.     /**
  177.      * Specifies the code fragment that is used to create this action.  The following replacement
  178.      * variables are allowed in the code fragment:
  179.      * %name%   the name of the class/bean
  180.      * %class%  full classname of the class/bean
  181.      * %arg%    method argument used for input action data
  182.      * @return the new expression
  183.      * @see #getExpr
  184.      */
  185.     public void setExpr(String e) {
  186.         expr = e;
  187.         if (expr != null && expr.startsWith(".import"))
  188.             System.err.println("**Warning: Import specifications are not supported in action descriptors");
  189.     }
  190.  
  191.     private String form;
  192.     private String type;
  193.     private String init;
  194.     private String expr;
  195. }
  196.